/**
 * 格式化时间
 * @param format 时间
 * @returns format
 */
Date.prototype.format = function(format)
{
	var o = {
		"M+" : this.getMonth()+1, //month
		"d+" : this.getDate(), //day
		"h+" : this.getHours(), //hour
		"m+" : this.getMinutes(), //minute
		"s+" : this.getSeconds(), //second
		"q+" : Math.floor((this.getMonth()+3)/3), //季度
		"S" : this.getMilliseconds() //millisecond
	};

	if(/(y+)/.test(format)) 
	{
		format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
	}

	for(var k in o)
	{
		if(new RegExp("("+ k +")").test(format))
		{
			format = format.replace(RegExp.$1, RegExp.$1.length==1 ? ("000"+ o[k]).substr((""+ o[k]).length): ("00"+ o[k]).substr((""+ o[k]).length));
		}
	}
	return format;
};

/**
 * 计算两个时间之间的差值，返回 00:00:00 格式
 * @param beginDate 开始时间
 * @param endDate 结束时间
 * @returns timeLength
 */
Date.prototype.dataDiff = function(beginDate, endDate)
{
	var timeLength = "";
	if(isBlank(beginDate) || isBlank(endDate))
	{
		return;
	}
	var hour = now.getHours() - phone.SiginTime.getHours();
	var min = beginDate.getMinutes() - endDate.getMinutes();
	var sec = beginDate.getSeconds() - endDate.getSeconds();
	if( min < 0)
	{
		min = 60 + min;
	}
	if(sec < 0)
	{
		min = min - 1;
		sec = 60 + sec;
	}
	if(min < 10)
	{
		min = "0" + min;
	}
	if(sec < 10)
	{
		sec = "0" + sec;
	}
	timeLength = min + ":" + sec;
	return timeLength;
};